package com.xiaoyu.lanling.feature.invite.viewholder

import `in`.srain.cube.views.list.ViewHolderBase
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.xiaoyu.lanling.R
import com.xiaoyu.lanling.feature.invite.model.InviteEarnItem
import com.xiaoyu.lanling.media.image.ImageViewUtil
import com.xiaoyu.lanling.view.UserAvatarDraweeView
import com.xiaoyu.lanling.view.text.UserNameTextView

class InviteEarningViewHolder : ViewHolderBase<InviteEarnItem>() {
    private lateinit var avatar: UserAvatarDraweeView
    private lateinit var name: UserNameTextView
    private lateinit var earnDesc: TextView
    private lateinit var time: TextView
    private lateinit var earnMoney: TextView

    override fun createView(layoutInflater: LayoutInflater, parent: ViewGroup): View? {
        val rootView = layoutInflater.inflate(R.layout.invite_earning_detail_item, parent, false)
        avatar = rootView.findViewById(R.id.avatar)
        name = rootView.findViewById(R.id.user_name)
        earnDesc = rootView.findViewById(R.id.invite_distribution)
        time = rootView.findViewById(R.id.time)
        earnMoney = rootView.findViewById(R.id.invite_distribution_button)
        return rootView
    }

    override fun showData(position: Int, itemData: InviteEarnItem) {
        ImageViewUtil.loadImage(avatar, itemData.loadParam)
        name.setUser(itemData.user)
        earnDesc.setText(itemData.earnDesc)
        time.setText(itemData.time)
        earnMoney.text = itemData.money
    }
}